<template>
  <view v-if="template">
    <s-layout :title="title" navbar="custom1" :bgStyle="template.style?.background" color='#333333'
              onShareAppMessage>
    
		<view class="advertise">
		  <image class="city" src="https://xyh-static-app.oss-cn-hangzhou.aliyuncs.com/storage_2/storage/qt/202405241554213561.png"></image>
		  <view style="width:100%;height:160rpx;background-color:#FFFFFF;"></view>
		</view>
		
		<view class="botttom_view">
		  <view class="apply" @click="btnClick">申请入驻</view>
		</view>
    </s-layout>
  </view>
</template>

<script setup>
import {computed, reactive, ref} from 'vue';
import {onLoad, onReachBottom} from '@dcloudio/uni-app';
import sheep from '@/sheep';
import merchantApi from  '@/sheep/api/merchant'
import dayjs from 'dayjs';
import _ from 'lodash';
import assNavbar from '@/components/ass-navbar.vue'

const template = computed(() => sheep.$store('app').template?.home);

const title = ref('商家入驻')

const status = ref(-1);

const remark = ref('');

const applyShow = computed(()=>{
	if (status.value==0||status.value==2||status.value==-1){
		return true
	}else if(status.value==1){
		return false;
	}
});

const btnClick = ()=>{
	
	console.log('btnClick',status.value)
	
	if(status.value==-1){//身份未申请时，跳转到申请页面
		uni.navigateTo({
			url:'/pages/merchant/apply',
		})
	}else if(status.value==0||status.value==2){ //身份审核中，跳转到结果页面
		uni.navigateTo({
			url:'/pages/merchant/result?status='+status.value+'&remark='+remark.value,
		})
	}else if(status.value==1){
		uni.navigateTo({
			url:'/pages/merchant/result?status='+status.value+'&remark='+remark.value,
		})
	}
}

const getStatus = async()=>{

  const {data,error} = await merchantApi.getStatus();

  console.log('getStatus.data',data);
  
  if(error===0){
	  status.value = data.status;
	  remark.value = data.remark
	  
  }
}

onLoad(()=>{
  getStatus();
})

</script>

<style lang="scss" scoped>
.advertise {
  margin-left: 10rpx;
  margin-right: 10rpx;
  margin-top: 30rpx;

  .city {
    width: 100%;
    height: 1180rpx;
  }
}


.botttom_view {
  position: fixed;
  bottom: 0rpx;
  width: 100%;
  height: 140rpx;
  background-color: #FFFFFF;


  .apply {
    background-color: #47DFBD;
    width: calc(100% - 40rpx);
    height: 80rpx;
    border-radius: 50rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #FFFFFF;
    font-family: Source Han Sans;
    font-weight: 400;
    font-size: 32rpx;
    letter-spacing: 1rpx;;
    margin-bottom: 40rpx;
    margin-top: 20rpx;
	margin-left:20rpx;
	margin-right:20rpx;
  }
}
</style>
